package modelLag;
import java.util.ArrayList;
import java.util.Date;

/**
 * Description of the class Order.
 * 
 * @author (Christian, Umut, Christoffer, Patrick, Simon) 
 * @project (Semesterprojekt)
 * @version (2014.12.09)
 */
public class Order extends Transaction
{
    public static int IDCounter = 0;
    private int orderID;
    private int status;
    private Customer customer;
    private ArrayList<PartOrder> partOrders;

    /**
     * Constructor for objects of class Order
     *
     *@param "OrderID" is the user input for the ID of a Order.
     * @param "date" is the date of the creation of the order.
     * @param "status" is the staus of the order.
     * @param "customers" shows a couple of information about the customer.
     * @param "employees" shows a couple of information about the employee who serves the customer.
     * @param ArrayList<PartOrder> the order has a list of partOrders.
     */
    public Order(Customer customer, Employee employee){
        // Call to superclass controller
    	super(employee);
    	// initializing the instance variables and making an ArrayList as well.
        // keep track of the next order number in line
        IDCounter += 1;
        orderID = IDCounter;
        status = 0;
        date = new Date();
        this.customer = customer;
        this.employee = employee;
        partOrders = new ArrayList<PartOrder>();
    }
   
    /**
    * The ArrayList Partorder adds partOrders in the Orderlist.
    */
    public void addPartOrder(PartOrder partOrder){
        partOrders.add(partOrder);
    }
    
    /**
    * Return an object of the type Customer.
    */
    public Customer getCustomer(){
        return customer;
    }
    
    /**
    * Return the orderID of the order.
    */
    public int getID(){
        return orderID;
    }
        
    /**
    * Return the employee of the order.
    */
    public Employee getEmployee(){
        return employee;
    }
    
    /**
    * Return the partOrders.
    */
    public ArrayList<PartOrder> getPartOrders(){
        return partOrders;
    }
    
    /**
    * Return the total price after any discounts has been calculated.
    */
    public double getTotalWithDiscount(){
        return total - (total*((customer.getType().getDiscountRate())/100));
    }
    
    /**
    * Sets the status of an Order.
    * 
    * @param s is whether an Order is active, ready to be packed, packed and delivered/picked up.
    */
    public void setStatus(int s){
        if(s >= 0 || s <= 3) 
            this.status = s;
    }
    
}


